<style type="text/css"></style>
<template>
    <i-form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="100">
        <Form-item label="钥匙自编号" prop="keyid">
            <i-input v-model="formValidate.keyid" placeholder="请输入钥匙自编号"></i-input>
        </Form-item>
        <Form-item label="钥匙存放柜编号(可选)" prop="keystoreid">
            <i-input v-model="formValidate.keystoreid" placeholder="请输入钥匙存放柜编号(可选)"></i-input>
        </Form-item>
        <Form-item>
            <i-button @click="handleSubmit('formValidate')" type="primary">提交</i-button>
            <i-button type="ghost" @click="jumpPage()" style="margin-left: 8px">返回</i-button>
        </Form-item>
    </i-form>
</template>
<script>
    import apiUtil from '../../assets/utils/api_util';
    import baseUtil from '../../assets/utils/base-util';


    /**
     *  车牌号 platenum, 车辆卡编号 cardid，
     *  车辆自编号 carcode, 车辆车架号 carsn,
     *  车身颜色 color， 车辆品牌 brand
     *  参数: 行驶里程数 drivedmiles
     */


    export default {
        data() {
            return {
                formValidate: {
                    //添加字段
                    keyid: '',
                    keystoreid: '',
                },
                ruleValidate: {},
            }
        },
        components: {},
        mounted: function () {
            // this.uploadList();
        },
        methods: {
            //跳转
            jumpPage: function (id, url) {
                this.$router.back(-1)

            },
            handleSubmit(name) {

                let that = this;
                let model = this.$refs[name].model;
                this.$refs[name].validate((valid) => {
                    that.addData(model);
                })
            },
            //添加
            addData: function (model) {
                let that = this;

                model.Forcarid = this.$route.query.id;
                let params = that.$qs.stringify(model);
                this.$Loading.start();

                apiUtil.post(that, apiUtil.urls.AddCarKey, params, function (res) {
                    that.$Loading.finish();

                    this.$Notice.warning({
                        top: 50,
                        duration: 3,
                        title:'添加成功!'
                    })
                    // that.$Modal.confirm({
                    //     title: '操作成功',
                    //     content: '请选择下一步操作',
                    //     okText: '继续添加',
                    //     cancelText: '返回列表',
                    //     onOk: () => {
                    //         baseUtil.pageJump(that, '', 'CarList')
                    //     },
                    //     onCancel: () => {
                    //         baseUtil.pageJump(that, '', 'CarAdd')
                    //     }
                    // });

                });
            },

        }
    }
</script>
